package com.hejjon.controller;

import com.hejjon.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by caoshi at 19:59 2021-08-18
 */
@RestController
public class DemoController {

    @Value("${user.username:zhangsan}")
    private String userName;

    @Value("${user.age:19}")
    private int age;


    private static String sex;

    @Value("${user.sex}")
    public void setSex(String sex) {
        DemoController.sex = sex;
    }

    public String getSex() {
        return sex;
    }

    @Autowired
    private UserService service;

    @RequestMapping("/demo")
    public String demo() {
        System.out.println(userName + " " + age + " " + sex);

        //UserService service = new UserService();
        String info = service.getInfo();
        System.out.println(info);

        return userName + " " + age + " " + sex + " " + info;
    }







}
